#include "stdlib.h"
 #include "stdio.h"
 #include <assert.h>
 #include <string.h>
 
 //对象拷贝
 
 typedef struct _DATA
{
	int value;
    struct _DATA* (*copy) (struct _DATA* pData);
}DATA;

struct _DATA* data_copy_A(struct _DATA* pData)
{
    DATA* pResult = (DATA*)malloc(sizeof(DATA));
    assert(NULL != pResult);
    memmove(pResult, pData, sizeof(DATA));
    return pResult;
}; 

struct _DATA* clone(struct _DATA* pData)
{
    return pData->copy(pData);
};
 
 int main()
 {
     DATA data_A = {8,data_copy_A};
	 DATA* data_B = clone(&data_A);
     printf("data B's num = %d.\n",data_B->value);
     return 0;
 }